<!-- 经销商登录页 -->
<template>
	<view>
		<view class="title">
			账号登录
		</view>
		<view class="input-box">
			<input type="text" value="" placeholder="输入账号" @input="mobile"/>
		</view>
		<view class="input-box" style="margin-top: 84rpx;">
			<input type="password" value="" placeholder="密码" @input="password"/>
		</view>
		<view class="btns" @click="login">
			登录
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobiles:"",
				passwords:""
			}
		},
		onLoad() {
		},
		methods: {
			gotoindex() {
				uni.switchTab({
					url:"../index/index"
				})
			},
			mobile(e) {
				this.mobiles = e.detail.value;
			},
			password(e) {
				this.passwords = e.detail.value;
			},
			login() {
				let that = this;
				if(that.mobiles == "") {
					that.$refs.uToast.show({
						title: "帐号不能为空",
						type: 'error',
						icon: false
					})
					return;
				};
				if(that.passwords == "") {
					that.$refs.uToast.show({
						title: "密码不能为空",
						type: 'error',
						icon: false
					})
					return;
				};
				that.$myRequest({
					url: 'addons/track/agent/login', //请求地址
					method: 'POST', //请求方式
					data: {
						mobile: that.mobiles,
						password: that.passwords
					} //请求参数
				}).then(res => {
					if(res.data.code == 1) {
						uni.setStorageSync("token",res.data.data.userinfo.token);
						uni.setStorageSync("userinfo",res.data.data.userinfo);
						uni.redirectTo({
							url:"../index/scaning"
						})
					} else {
						that.$refs.uToast.show({
							title: res.data.msg,
							type: 'error',
							icon: false
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.title {
		width: 83%;
		font-size: 48rpx;
		color: #333333;
		line-height: 66rpx;
		margin: 68rpx auto 0;
		font-weight: 500;
	}
	.input-box {
		width: 83%;
		height: 72rpx;
		margin: auto;
		border-bottom: 2rpx solid #E2E2E2;
		margin-top: 106rpx;
		input {
			font-size: 28rpx;
			width: 100%;
		}
	}
	.btns {
		width: 83%;
		margin: auto;
		text-align: center;
		height: 88rpx;
		line-height: 88rpx;
		color: #FFFFFF;
		background-color: #1F70FF;
		border-radius: 8rpx;
		margin-top: 80rpx;
	}
</style>
